package com.aaa.cs.controller;

import com.aaa.common.util.Result;
import com.aaa.cs.entity.Car;
import com.aaa.cs.service.CarService;
import org.springframework.web.bind.annotation.*;


import javax.annotation.Resource;

/**
 * (Car)表控制层
 *
 * @author makejava
 * @since 2020-11-18 15:44:18
 */
@RestController
@RequestMapping("car")
public class CarController {
    /**
     * 服务对象
     */
    @Resource
    private CarService carService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Result selectOne(Integer id) {
        return this.carService.queryById(id);
    }

    /**
     * 分页加各种条件查询
     * @param pageNo
     * @param pageSize
     * @param car
     * @return
     */
    @GetMapping("queryPageByParam")
    public Result queryPageByParam(Integer pageNo, Integer pageSize, Car car){
        return carService.queryPageByParam(pageNo,pageSize,car);
    }

    @GetMapping("deleteByCarId")
    public Result deleteByCarId(Integer id){
        return carService.deleteByCarId(id);
    }

    @GetMapping("insertOrUpdate")
    public Result insertOrUpdate(Car car){
        return carService.insertOrUpdate(car);
    }

    @GetMapping("queryAll")
    public Result queryAll(Car car){
        return carService.queryAll(car);
    }

    /**
     * 修改数据
     *
     * @param car 实例对象
     * @return 实例对象
     */
    @PutMapping("update")
    public Car update(@RequestBody Car car) {
        return this.carService.update(car);
    }
}